﻿using DataAcquisitionDAL;
using SqlSugar;

namespace DataAcquisitionBLL
{
    public class TestRecord
    {
        /// <summary> 添加试压记录
        /// 
        /// </summary>
        /// <param name="obj"></param>
        public Response AddTestRecord(TestRecordModel obj)
        {
            Response response = Response.DefaultResponse();
            List<TestRecordModel> list = new List<TestRecordModel>();
            list.Add(obj);
            int result = SqlSugarHelper.Insertable(list);
            if (result > 0)
            {
                response.Code = 200;
                response.Msg = string.Format("试压记录添加成功");
            }
            else
            {
                response.Msg = string.Format("试压记录添加失败");
            }
            return response;
        }

        /// <summary> 查询试压记录
        /// 
        /// </summary>
        /// <param name="obj"></param>
        public Response InquireableTestRecord(string project_id)
        {
            Response response = Response.DefaultResponse();
            Dictionary<string, Object> where = new Dictionary<string, Object>();
            where["project_id"] = project_id;
            List<TestRecordModel>list = SqlSugarHelper.DB.Queryable<TestRecordModel>().WhereColumns(where).OrderBy(it=>it.Start_time, OrderByType.Desc).ToList();
            if (list.Count > 0)
            {
                response.Code = 200;
                response.Msg = string.Format("试压记录");
                response.Data = list;
            }
            else
            {
                response.Msg = string.Format("未查询到试压记录");
            }
            return response;
        }
    }
}
